home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / ear / mui23dev.lha / MUI / Developer / C / Examples / ShowImg.c < prev    next >
C/C++ Source or Header  |  1994-12-23  |  3KB  |  136 lines

  1. #include "demo.h"
  2.  
  3.  
  4. /*
  5. ** We want our images displayed in a group with five columns.
  6. */
  7.  
  8. #define cols 4
  9. #define startimg 11
  10.  
  11. /*
  12. ** This is a image object at its standard size.
  13. */
  14.  
  15. #define FixedImg(x) ImageObject,\
  16.     ButtonFrame,\
  17.     MUIA_InputMode, MUIV_InputMode_RelVerify,\
  18.     MUIA_Image_FreeHoriz, FALSE,\
  19.     MUIA_Image_FreeVert, FALSE,\
  20.     MUIA_Image_Spec, x,\
  21.     MUIA_Background, MUII_BACKGROUND,\
  22.     End
  23.  
  24.  
  25. /*
  26. ** This is a resizable image.
  27. ** Since the user might have configured a fixed size image,
  28. ** we need to enclose our image in groups of spacing objects
  29. ** to make it centered. The spacing objects have a very little
  30. ** weight, so the images will get every pixel they want.
  31. */
  32.  
  33. #define sp            RectangleObject, MUIA_Weight, 1, End
  34. #define hcenter(obj)  HGroup, Child, sp, Child, obj, Child, sp, End
  35. #define vcenter(obj)  VGroup, Child, sp, Child, obj, Child, sp, End
  36. #define hvcenter(obj) hcenter(vcenter(obj))
  37.  
  38. #define FreeImg(x) hcenter(vcenter(xFreeImg(x)))
  39.  
  40. #define xFreeImg(x) ImageObject,\
  41.     ButtonFrame,\
  42.     MUIA_InputMode, MUIV_InputMode_RelVerify,\
  43.     MUIA_Image_FreeHoriz, TRUE,\
  44.     MUIA_Image_FreeVert, TRUE,\
  45.     MUIA_Image_Spec, x,\
  46.     MUIA_Background, MUII_BACKGROUND,\
  47.     End
  48.  
  49.  
  50.  
  51.  
  52. int main(int argc,char *argv[])
  53. {
  54.     ULONG signal;
  55.     APTR App,WI_Master;
  56.     APTR FixGroup,FreeGroup;
  57.     int i;
  58.  
  59.     init();
  60.  
  61.  
  62.     /*
  63.     ** Create the application.
  64.     ** Note that we generate two empty groups without children.
  65.     ** These children will be added later with OM_ADDMEMBER.
  66.     */
  67.  
  68.     App = ApplicationObject,
  69.         MUIA_Application_Title      , "ShowImg",
  70.         MUIA_Application_Version    , "$VER: ShowImg 10.11 (23.12.94)",
  71.         MUIA_Application_Copyright  , "©1992/93, Stefan Stuntz",
  72.         MUIA_Application_Author     , "Stefan Stuntz",
  73.         MUIA_Application_Description, "Show MUI standard images",
  74.         MUIA_Application_Base       , "SHOWIMG",
  75.  
  76.         SubWindow, WI_Master = WindowObject,
  77.             MUIA_Window_ID, MAKE_ID('M','A','I','N'),
  78.             MUIA_Window_Title, "MUI Standard Images",
  79.  
  80.             WindowContents, HGroup,
  81.  
  82.                 Child, VGroup,
  83.                     Child, VSpace(0),
  84.                     Child, FixGroup = ColGroup(cols), GroupFrameT("Minimum Size"), End,
  85.                     Child, VSpace(0),
  86.                     End,
  87.  
  88.                 Child, FreeGroup = ColGroup(cols), GroupFrameT("Free Size"), End,
  89.  
  90.                 End,
  91.             End,
  92.         End;
  93.  
  94.     if (!App) fail(App,"Failed to create Application.");
  95.  
  96.  
  97.     /*
  98.     ** No we insert the image elements in our groups.
  99.     */
  100.  
  101.     for (i=0;i<MUII_Count-startimg;i++)
  102.     {
  103.         DoMethod(FixGroup,OM_ADDMEMBER,FixedImg(i+startimg));
  104.         DoMethod(FreeGroup,OM_ADDMEMBER,FreeImg(i+startimg));
  105.     }
  106.  
  107.  
  108.     /*
  109.     ** Append some empty objects to make our columnized
  110.    ** group contain exactly cols*rows elements.
  111.     */
  112.  
  113.     while (i % cols)
  114.     {
  115.         DoMethod(FixGroup,OM_ADDMEMBER,HVSpace);
  116.         DoMethod(FreeGroup,OM_ADDMEMBER,HVSpace);
  117.         i++;
  118.     }
  119.  
  120.  
  121.     /*
  122.     ** Simplest possible MUI input loop.
  123.     */
  124.  
  125.     DoMethod(WI_Master,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,App,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  126.     set(WI_Master,MUIA_Window_Open,TRUE);
  127.  
  128.     while (DoMethod(App,MUIM_Application_Input,&signal) != MUIV_Application_ReturnID_Quit)
  129.         if (signal)
  130.             Wait(signal);
  131.  
  132.     set(WI_Master,MUIA_Window_Open,FALSE);
  133.  
  134.     fail(App,NULL);
  135. }
  136.